#ifndef _VIEWPORT_H_
#define _VIEWPORT_H_
#include "../shapes.h"
#include <map>

//typedef int (*cbk)(const SRect & rect)

class CViewport
{
private:
	enum _e_vpmode
	{
		VP2D = 1,
		VP3D
	};
	mutable _e_vpmode _viewportMode;
	mutable unsigned int _matrixMode;
	SRect _rct; // Viewport stores the screen rectangle

	unsigned int _idx;
	std::map<unsigned int, int(*)(const SRect & rect)> _listeners;

public:
	CViewport(const SRect & rct);
	void resize(int w, int h);
	void activate() const;
	void resetMode() const;
	void switchTo2DMode() const;
	void switchTo3DMode() const;
	void setMatrixMode(unsigned int matrixMode) const;
	inline const SRect & getRect(void) const {return _rct;}
	unsigned int attach(int (*cbk)(const SRect & rect));
	void detach(unsigned int id);
};

#endif //_VIEWPORT_H_
